package gov.pr.celepar.sentinela.taglibs.info;

import gov.pr.celepar.sentinela.Constants;
import gov.pr.celepar.sentinela.client.SentinelaLogin;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.http.HttpSession;

/**
 * @author Fabio Sgoda
 * @since 27/06/2005
 * @version 1.0
 */
public class PathLastFunction extends BodyTagSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public int doStartTag() throws JspException {

		return super.doStartTag();
	}

	public int doEndTag() throws JspException {
		StringBuffer out = new StringBuffer();

		SentinelaLogin login;
		HttpSession session = this.pageContext.getSession();
		login = (SentinelaLogin) session
				.getAttribute(Constants.SESSION_SENTINELA_LOGIN);
		if (login == null)
			return super.doEndTag();

		out.append(login.getPathLastFuncao());

		try {
			this.pageContext.getOut().write(out.toString());
		} catch (Exception ex) {
			throw new JspException(ex);
		}

		return super.doEndTag();
	}

}